<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>消息</title>
    <link rel="stylesheet" type="text/css" href="../../css/main.css" />
    <style>
        .box {
            height: 7px;
            background: #c3c3c3;
            margin-top: 11px;
        }

        .information-two {
            /*margin-top:26px;*/
            background: #ea5718;
            /*height: 28px;*/
            padding: 8px 40px;
            /*line-height: 28px;*/
            color: #fff;
            text-align: center;
            border-radius: 15px;
        }

        .information-three {
            margin: 24px 16px 4px 16px;
            border: 2px solid #c9c9ca;
            border-radius: 8px;
            color: #727272;
        }

        .in-t-one {
            margin-top: 11px;
            font-size: 13px;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            overflow: hidden;
            /*margin: 11px 15px;*/
            margin: 0px 15px;
            height: 15px;
        }

        .info_title {
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            overflow: hidden;
            margin: 11px 15px;
        }

        .in-t-two {
            margin-top: 11px;
            border-top: 2px solid #c9c9ca;
            padding: 5px 15px;
        }

        .outcat{
          width: 166px;
          height: auto;
          display: block;
          margin: 0 auto;
        }
        .cat {
            text-align: center;
            margin-top: 144px;
        }

        .zi {
            margin-top: 18px;
            color: #dedede;
        }

        body {
            background: #fff;
        }
    </style>

    <body>
        <div id="vm">

            <div class="big-box">
                <div class="box">
                </div>
                <div  v-if="iskong">
                    <!-- <img src="../../image/few/incat.png" alt="" class="outcat">
                    <div class="zi">
                        暂无任何消息
                    </div> -->
                    <div class="cat">
                        <img src="../../image/qq.jpg" alt="" class="outcat">
                        <div class="zi">
                            暂无任何消息
                        </div>
                    </div>
                </div>
                <div v-else v-for="item in messagelist">
                    <div style="text-align:center;margin-top: 26px;">
                        <span class="information-two">
                            {{showtimestyle(item.sendtime)}}
                        </span>
                    </div>
                    <div class="information-three">
                        <div class="info_title">
                            {{item.title}}
                        </div>
                        <div class="in-t-one" v-html="item.msg2">

                        </div>
                        <div class="in-t-two" v-on:click="OpenMessagedetailWin(item.id,item.message_type,item.articleid)">
                            详细消息
                        </div>
                    </div>

                </div>

            </div>

        </div>
    </body>
    <script type="text/javascript" src="../../script/api.js"></script>
    <script type="text/javascript" src="../../script/config.js"></script>
    <script type="text/javascript" src="../../script/rest.js"></script>
    <script type="text/javascript" src="../../script/vue.2.5.js"></script>
    <script type="text/javascript" src="../../script/zepto.js"></script>
    <script type="text/javascript" src="../../script/showdate.js"></script>
    <script type="text/javascript" src="../../script/faskclick.js"></script>
    <script type="text/javascript">
        var uid = $api.getStorage('uid');
        var vm = new Vue({
            el: '#vm',
            data: {
                messagelist: [],
                page: 1,
                iskong: false,
            },
            created: function() {
                var _this = this;
                apiready = function() {
                    _this.init();
                    api.parseTapmode();
                    if ('addEventListener' in document) {
                        document.addEventListener('DOMContentLoaded', function() {
                            FastClick.attach(document.body);
                        }, false);
                    }
                }
            },
            methods: {
                init: function() {
                    var _this = this;
                    if (uid) {
                        var ajpush = api.require('ajpush');
                        ajpush.setBadge({
                            badge: 0
                        });
                        api.addEventListener({
                            name: 'scrolltobottom',
                            extra: {
                                threshold: 80 //设置距离底部多少距离时触发，默认值为0，数字类型
                            }
                        }, function(ret, err) {
                            _this.page = _this.page + 1;
                            _this.getmessagelist();
                        });
                        _this.getmessagelist();
                    } else {
                        _this.iskong = true;
                        api.openFrame({
                            name: 'login_introduction',
                            url: '../myself/login_introduction.html',
                            rect: {
                                x: 0,
                                y: 0,
                                w: 'auto',
                                h: 'auto'
                            },
                            bounces: false,
                            bgColor: 'rgba(0,0,0,0.7)',
                            vScrollBarEnabled: true,
                            hScrollBarEnabled: true
                        });
                    }
                },
                showtimestyle(messagetime) {
                    // 获取发送消息的时间的年份  月 日 时  分
                    return Mou.showdate(messagetime)


                    // var messageyear = messagetime.split(' ')[0].split('-')[0];
                    // var messagemonth = messagetime.split(' ')[0].split('-')[1];
                    // var messageday = messagetime.split(' ')[0].split('-')[2];
                    // var messagehour = messagetime.split(' ')[1].split(':')[0];
                    // var messageminute = messagetime.split(' ')[1].split(':')[1];
                    // // 获取今年的年份
                    // var myDateYear = new Date().getFullYear();
                    // if (messageyear == myDateYear) {
                    //     return messagemonth + '-' + messageday + ' ' + messagehour + ':' + messageminute
                    // } else {
                    //     return messageyear + '-' + messagemonth + '-' + messageday + ' ' + messagehour + ':' + messageminute
                    // }

                },
                getmessagelist: function() {
                    var _this = this;
                    new rest().post('getMessageList').datae({
                        'uid': uid,
                        'page': _this.page,
                        'psize': '10'
                    }).success(function(res) {
                        if (res.flag == 1) {
                            if (res.msg.count == 0) {
                                _this.iskong = true;
                            } else {
                                if (res.msg.data == '') {
                                    _this.page = _this.page;
                                    api.toast({
                                        msg: '没有更多了',
                                        duration: 2000,
                                        location: 'middle'
                                    });
                                } else {
                                    _this.messagelist = _this.messagelist.concat(res.msg.data);
                                    for (var i = 0; i < res.msg.data.length; i++) {
                                        _this.OpenMessageDetail(res.msg.data[i].id)
                                    }
                                }
                            }
                        }
                    }).error(function(err) {
                        console.log(JSON.stringify(err))
                    }).run()
                },
                OpenMessageDetail: function(message_id) {
                    var _this = this;
                    new rest().get('getMessageDetail').datae({
                        'uid': uid,
                        'message_id': message_id
                    }).success(function(res) {
                        if (res.flag == 1) {
                            api.sendEvent({
                                name: 'yiduflag'
                            });
                        } else {
                            api.toast({
                                msg: '信息不存在',
                                duration: 2000,
                                location: 'middle'
                            });
                        }

                    }).error(function(err) {
                        console.log(JSON.stringify(err))
                    }).run()
                },
                //打开消息详情页面
                OpenMessagedetailWin: function(messageid,messagetype,messagearticeid) {
                  if(messagetype==2){
                    api.openWin({
                        name: 'videodetail_win',
                        url: '../VIP/videodeail.html',
                        animation: {
                            type: "fade", //动画类型（详见动画类型常量）
                            subType: "from_right", //动画子类型（详见动画子类型常量）
                            duration: 300 //动画过渡时间，默认300毫秒
                        },
                        slidBackEnabled:false,
                        pageParam: {
                            videoid: messagearticeid
                        }
                    });
                  }else{
                    api.openWin({
                        name: 'verify-informationed_win',
                        url: 'verify-informationed_win.html',
                        animation: {
                            type: "fade", //动画类型（详见动画类型常量）
                            subType: "from_right", //动画子类型（详见动画子类型常量）
                            duration: 300 //动画过渡时间，默认300毫秒
                        },
                        pageParam: {
                            messageid: messageid
                        }
                    });
                  }

                }
            }
        })
    </script>


</html>
